1
|
|
|
// export function msToTime(valueMsEpoch: number) { |
2
|
|
|
// const seconds = Math.floor((valueMsEpoch / 1000) % 60); |
3
|
|
|
// const minutes = Math.floor((valueMsEpoch / (1000 * 60)) % 60); |
4
|
|
|
// const hours = Math.floor((valueMsEpoch / (1000 * 60 * 60)) % 24); |
5
|
|
|
// |
6
|
|
|
// return hours + ':' + minutes + ':' + seconds; |
7
|
|
|
// } |
8
|
|
|
// |
9
|
|
|
// export function msToClock(valueMsEpoch: number) { |
10
|
|
|
// const minutes = Math.floor((valueMsEpoch / (1000 * 60)) % 60); |
11
|
|
|
// const hours = Math.floor((valueMsEpoch / (1000 * 60 * 60)) % 24); |
12
|
|
|
// |
13
|
|
|
// return hours + ':' + minutes; |
14
|
|
|
// } |
15
|
|
|
|
16
|
|
|
function getTimezoneList(): { [key: number]: string } { |
17
|
|
|
const timezoneTable: { [key: number]: string } = { |
18
|
|
|
'-43200000': '(GMT -12:00) Eniwetok, Kwajalein', |
19
|
|
|
'-39600000': '(GMT -11:00) Midway Island, Samoa', |
20
|
|
|
'-36000000': '(GMT -10:00) Hawaii', |
21
|
|
|
'-32400000': '(GMT -9:00) Alaska', |
22
|
|
|
'-28800000': '(GMT -8:00) Pacific Time', |
23
|
|
|
'-25200000': '(GMT -7:00) Mountain Time', |
24
|
|
|
'-21600000': '(GMT -6:00) Central Time, Mexico City', |
25
|
|
|
'-18000000': '(GMT -5:00) Eastern Time, Bogota, Lima', |
26
|
|
|
'-14400000': '(GMT -4:00) Atlantic Time, Caracas, La Paz', |
27
|
|
|
'-12600000': '(GMT -3:30) Newfoundland', |
28
|
|
|
'-10800000': '(GMT -3:00) Brazil, Buenos Aires, Georgetown', |
29
|
|
|
'-7200000': '(GMT -2:00) Mid-Atlantic', |
30
|
|
|
'-3600000': '(GMT -1:00) Azores, Cape Verde Islands', |
31
|
|
|
'0': '(GMT) Western Europe Time, London', |
32
|
|
|
'3600000': '(GMT +1:00) Brussels, Copenhagen, Madrid, Paris', |
33
|
|
|
'7200000': '(GMT +2:00) Kaliningrad, South Africa', |
34
|
|
|
'10800000': '(GMT +3:00) Baghdad, Riyadh, Moscow', |
35
|
|
|
'12600000': '(GMT +3:30) Tehran', |
36
|
|
|
'14400000': '(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', |
37
|
|
|
'16200000': '(GMT +4:30) Kabul', |
38
|
|
|
'18000000': '(GMT +5:00) Islamabad, Karachi, Tashkent', |
39
|
|
|
'19800000': '(GMT +5:30) Bombay, Calcutta, Madras, New Delhi', |
40
|
|
|
'21600000': '(GMT +6:00) Almaty, Dhaka, Colombo', |
41
|
|
|
'25200000': '(GMT +7:00) Bangkok, Hanoi, Jakarta', |
42
|
|
|
'28800000': '(GMT +8:00) Beijing, Perth, Singapore, Hong Kong', |
43
|
|
|
'32400000': '(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk', |
44
|
|
|
'34200000': '(GMT +9:30) Adelaide, Darwin', |
45
|
|
|
'36000000': '(GMT +10:00) Eastern Australia, Guam, Vladivostok', |
46
|
|
|
'39600000': '(GMT +11:00) Magadan, Solomon Islands', |
47
|
|
|
'43200000': '(GMT +12:00) Auckland, Wellington, Fiji', |
48
|
|
|
}; |
49
|
|
|
return timezoneTable; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
// export function timezoneDropdown(selectedOffset: string): { text: string, value: string, selected: boolean }[] { |
53
|
|
|
// const timezones = getTimezoneList(); |
54
|
|
|
// // foreach timezone |
55
|
|
|
// const formattedTimezones = Object.keys(timezones).map((offset) => ({ |
56
|
|
|
// text: timezones[offset], |
57
|
|
|
// value: offset, |
58
|
|
|
// selected: offset === selectedOffset, |
59
|
|
|
// })); |
60
|
|
|
// return formattedTimezones; |
61
|
|
|
// } |
62
|
|
|
|
63
|
|
|
export function offsetToTimezone(offset: number) { |
64
|
|
|
const timezones = getTimezoneList(); |
65
|
|
|
return timezones[offset]; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
export const DEFAULT_LOCALE_TIMEZONE = {'locale': 'en', 'offset': 0, 'id': 'UTC'}; |
69
|
|
|
|